/*
 * Copyright (c) Jipzingking 2016.
 */

package sdfs.client;

import sdfs.datanode.DataNode;
import sdfs.protocol.IDataNodeProtocol;
import sdfs.server.Rpc;

import java.io.IOException;
import java.util.UUID;

public class DataNodeStub implements IDataNodeProtocol {

    private IDataNodeProtocol dataNode;

    public DataNodeStub()throws  Exception{
        this.dataNode = Rpc.refer(IDataNodeProtocol.class,"127.0.0.1",DataNode.DATA_NODE_PORT);
    }

    @Override
    public byte[] read(UUID fileUuid, int blockNumber, int offset, int size) throws IndexOutOfBoundsException, IOException {
        return dataNode.read(fileUuid,blockNumber,offset,size);
    }

    @Override
    public void write(UUID fileUuid, int blockNumber, int offset, byte[] b) throws IndexOutOfBoundsException, IOException {
        dataNode.write(fileUuid,blockNumber,offset,b);
    }
}
